package pri.syl.xiaowu.websocket.core.template;

import pri.syl.xiaowu.websocket.core.domain.HttpUpgradeRequest;
import pri.syl.xiaowu.websocket.core.exception.WebsocketException;

/**
 * @Author YunLong
 * @Date 2021/7/18 18:12
 * @Description websocket对应事件模板
 **/
public interface WebsocketRouteTemplate {

    /**
     * upgradeSuccessEvent
     *
     * @param request         request
     * @param channelTemplate channelTemplate
     */
    void upgradeSuccessEvent(HttpUpgradeRequest request, WebsocketChannelTemplate channelTemplate);

    /**
     * pingMessageEvent
     *
     * @param channelTemplate channelTemplate
     * @param messageTemplate messageTemplate
     */
    void pingMessageEvent(WebsocketChannelTemplate channelTemplate, WebsocketMessageTemplate messageTemplate);

    /**
     * pongMessageEvent
     *
     * @param channelTemplate channelTemplate
     * @param messageTemplate messageTemplate
     */
    void pongMessageEvent(WebsocketChannelTemplate channelTemplate, WebsocketMessageTemplate messageTemplate);

    /**
     * textMessageEvent
     *
     * @param channelTemplate channelTemplate
     * @param messageTemplate messageTemplate
     */
    void textMessageEvent(WebsocketChannelTemplate channelTemplate, WebsocketMessageTemplate messageTemplate);

    /**
     * binaryMessageEvent
     *
     * @param channelTemplate channelTemplate
     * @param messageTemplate messageTemplate
     */
    void binaryMessageEvent(WebsocketChannelTemplate channelTemplate, WebsocketMessageTemplate messageTemplate);

    /**
     * closeMessageEvent
     *
     * @param channelTemplate channelTemplate
     * @param messageTemplate messageTemplate
     */
    void closeMessageEvent(WebsocketChannelTemplate channelTemplate, WebsocketMessageTemplate messageTemplate);

    /**
     * errorEvent
     *
     * @param channelTemplate    channelTemplate
     * @param websocketException websocketException
     */
    void errorEvent(WebsocketChannelTemplate channelTemplate, WebsocketException websocketException);

    /**
     * connectionTimeoutEvent
     *
     * @param channelTemplate channelTemplate
     */
    void connectionTimeoutEvent(WebsocketChannelTemplate channelTemplate);

    /**
     * closeEvent
     *
     * @param channelTemplate channelTemplate
     */
    void closeEvent(WebsocketChannelTemplate channelTemplate);
}
